package com.xm.export.excel.converter;

import com.alibaba.fastjson.JSONObject;
import lombok.AllArgsConstructor;
import lombok.Getter;
import org.apache.commons.lang3.time.DateFormatUtils;

@Getter
@AllArgsConstructor
public class DateConverter implements Converter {
    private String from;
    private String pattern;

    @Override
    public ConverterType getType() {
        return ConverterType.date;
    }

    @Override
    public String convert(JSONObject target) {
        return DateFormatUtils.format(target.getDate(from), pattern);
    }
}
